{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3b9d0245",
   "metadata": {},
   "source": [
    "# python logging\n",
    "logger 可以通过两种方式创建\n",
    "    1. 通过文件创建，使用`logging.config.fileConfig(xxx.config)`进行录入\n",
    "    2. 通过程序代码创建，使用`logging.basicConfig(level,filter,formatter)`或者使用logging的添加方法进行设定\n",
    "## logging 级别\n",
    "1. basic\n",
    "2. debug\n",
    "3. info\n",
    "4. warning\n",
    "5. error\n",
    "6. critical\n",
    "## logging 模块\n",
    "1. logger\n",
    "2. handler\n",
    "3. filter\n",
    "4. formatter\n",
    "5. log产生顺序，中间传递的内容是logRecord： 程序->current logger->current logger's filter->parent logger -> parent logger's filter -> handler -> emit to platform\n",
    "`\n",
    "import logging\n",
    "logger = logging.getLogger(__name__)\n",
    "\n",
    "`\n",
    "### logger\n",
    "1. 截获程序中的log\n",
    "2. 判断log的级别，确定是否接收\n",
    "3. 将log包装成对象，然后指派到不同的handler\n",
    "`\n",
    "logger.setLevel()\n",
    "logger.addFilter()\n",
    "logger.removeFilter()\n",
    "logger.addHandler()\n",
    "logger.removeHandler()\n",
    "logger.propagate = False to disable log record propagations\n",
    "`\n",
    "\n",
    "### handler\n",
    "`\n",
    "ch  = logging.StreamHandler()\n",
    "formatter = logging.Formatter()\n",
    "ch.setLevel()\n",
    "ch.setFomatter(formatter)\n",
    "`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e10c883c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import logging\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "python3.6",
   "language": "python",
   "name": "python3.6"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "315px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
